package com.aliyun.messagemgt.repository.mappers;

import com.aliyun.messagemgt.common.dto.send.PushChannelInfo;
import com.aliyun.messagemgt.dto.PushChannelAdd;
import com.aliyun.messagemgt.dto.query.PushChannelQuery;
import com.aliyun.messagemgt.entities.PushChannelEntity;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Set;

/**
 * @author
 * @date
 */
public interface PushChannelMapper {

    /**
     * 通过描述查询推送渠道
     * @param pushChannelAdd
     * @return
     */
    int selectByDescription(PushChannelAdd pushChannelAdd);

    /**
     * 插入推送渠道
     * @param pushChannelAdd
     * @return
     */
    int insertPushChannel(PushChannelAdd pushChannelAdd);

    /**
     * 列出推送渠道列表
     * @param pushChannelQuery
     * @return
     */
    List<PushChannelEntity> listPushChannel(PushChannelQuery pushChannelQuery);

    /**
     * 更新推送渠道
     * @param pushChannelQuery
     * @return
     */
    int topPushChannel(PushChannelQuery pushChannelQuery);

    /**
     * 删除推送渠道
     * @param pushChannelQuery
     * @return
     */
    int delPushChannel(PushChannelQuery pushChannelQuery);

    /**
     * 修改推送渠道
     * @param pushChannelAdd
     * @return
     */
    int modPushChannel(PushChannelAdd pushChannelAdd);

    /**
     * 查询渠道详情
     * @param pushChannelId
     * @return
     */
    PushChannelEntity queryChannelDetail(@Param("pushChannelId") Long pushChannelId);

    /**
     * 先查询置顶渠道
     * @return
     */
    List<PushChannelEntity> queryTopChannel(PushChannelQuery pushChannelQuery);

    List<PushChannelEntity> listPushChannelNoTop(PushChannelQuery pushChannelQuery);

    /**
     * 更具id集合获取渠道信息
     *
     * @param channelIds
     * @return
     */
    List<PushChannelInfo> listChannelById(@Param("channelIds") List<Integer> channelIds);

    /**
     * 获取所有的channel
     *
     * @return
     */
    List<PushChannelInfo> listAllChannel();

    /**
     * 通过channelId 查询渠道信息
     * @param channelId id
     * @return 渠道
     */
    PushChannelInfo queryPushChannelInfoByChannelId(@Param("channelId") Integer channelId);

    @Update("update push_channel set off_msg = ${offMsg} where push_channel_id = ${pushChannelId}")
    Integer updateChannelOffMsg(@Param("pushChannelId") Integer pushChannelId, @Param("offMsg") Integer offMsg);

    /**
     * 启用/禁用
     *
     * @param pushChannelQuery
     * @return
     */
    int updateStatus(PushChannelQuery pushChannelQuery);

    int queryChannelBychatId(String chatId);

    /**
     * 根据渠道编码查询信息
     * @param channelCode 渠道棉麻
     * @return 返回编码集合
     */
    List<PushChannelEntity> queryByChannelCode(String channelCode);

    /**
     * 根据渠道账户名称查询
     * @param description 渠道账户名称查询
     * @return
     */
    List<PushChannelEntity> queryByChannelName(String description);

    PushChannelEntity queryChannelCodeById(String channelCode);

    /**
     * 根据id查询渠道信息
     * @param pushChannelId
     * @return
     */
    PushChannelEntity queryByChannelId(Long pushChannelId);

    /**
     * 通过编码查询
     * @param pushChannelAdd
     * @return
     */
    int selectByCode(PushChannelAdd pushChannelAdd);
}
